package com.weimei.conversionTreasure.activity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import android.content.Intent;
import android.os.Bundle;

import com.weimei.conversionTreasure.BR;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.app.AppViewModelFactory;
import com.weimei.conversionTreasure.databinding.ActivityJyDetailBinding;
import com.weimei.conversionTreasure.http.entity.SelKhBean;
import com.weimei.conversionTreasure.viewModel.JyDetailVM;
import com.weimei.conversionTreasure.viewModel.TotalVM;

import me.goldze.mvvmhabit.base.BaseActivity;

public class JyDetailActivity extends BaseActivity<ActivityJyDetailBinding, JyDetailVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_jy_detail;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public JyDetailVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, (ViewModelProvider.Factory) factory).get(JyDetailVM.class);
    }

    String id;
    @Override
    public void initParam() {
        super.initParam();
        id = getIntent().getStringExtra("id");
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        viewModel.getData(id);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 2){
            viewModel.customName.set(data.getStringExtra("name"));
            viewModel.customID.set(data.getStringExtra("id"));
        }
    }
}